﻿<UserControl x:Class="openPDC.UI.UserControls.OutputStreamDeviceDigitalUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="600"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:uc="clr-namespace:GSF.TimeSeries.UI.UserControls;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"
             Background="Transparent">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel Orientation="Vertical">

        <Grid x:Name="GridDetailView" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4" DataContext="{Binding Path=CurrentItem, Mode=TwoWay}" DataContextChanged="GridDetailView_DataContextChanged">
            
            <!--<Grid.Resources>
                <Style x:Key="{x:Type ListBoxItem}" TargetType="ListBoxItem">
                    <Setter Property="SnapsToDevicePixels" Value="true"/>
                    <Setter Property="OverridesDefaultStyle" Value="true"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <StackPanel Orientation="Vertical">
                                    <TextBlock x:Name="TextBlockLabel" Text="{Binding}" Visibility="Visible" HorizontalAlignment="Left"/>
                                    <TextBox x:Name="TextBoxLabel" Width="125" Text="{Binding ElementName=TextBlockLabel, Path=Text, Mode=TwoWay}" Visibility="Collapsed" CharacterCasing="Upper"/>
                                </StackPanel>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="true">
                                        <Setter TargetName="TextBoxLabel" Property="Visibility" Value="Visible"/>
                                        <Setter TargetName="TextBlockLabel" Property="Visibility" Value="Collapsed"/>
                                    </Trigger>
                                    <Trigger Property="IsSelected" Value="false">
                                        <Setter TargetName="TextBoxLabel" Property="Visibility" Value="Collapsed"/>
                                        <Setter TargetName="TextBlockLabel" Property="Visibility" Value="Visible"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

            </Grid.Resources>-->        
            
            <Grid.BindingGroup>
                <BindingGroup Name="input"/>
            </Grid.BindingGroup>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--Frist Row-->
            <TextBox x:Name="TextBoxLabel" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Text="{tsfBinding:Column Path=DisplayLabel}" CharacterCasing="Upper" TextWrapping="Wrap" Height="100" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" />            
            <!--<ListBox ItemsSource="{tsfBinding:Column Path=LabelCollection}" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="175" Height="90"/>-->            
            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" HorizontalAlignment="Right" VerticalAlignment="Top">
                <TextBlock Text="Label" Style="{StaticResource RequiredLabel}"/>
                <TextBlock Style="{StaticResource RequiredMarker}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right">
                <TextBlock Text="Load Order" Style="{StaticResource RequiredLabel}" />
                <TextBlock Style="{StaticResource RequiredMarker}"/>
            </StackPanel>
            <TextBox Grid.Row="0" Grid.Column="3" Text="{tsfBinding:Column Path=LoadOrder}" VerticalAlignment="Top" Width="35" />
            
            <!--Second Row-->
            <TextBox Grid.Row="1" Grid.Column="3" Text="{tsfBinding:Column Path=MaskValue}" VerticalAlignment="Top" Width="{StaticResource XXSmallItemSize}" />
            <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" >
                <TextBlock Text="Mask Value" Style="{StaticResource RequiredLabel}"/>
                <TextBlock Style="{StaticResource RequiredMarker}"/>
            </StackPanel>

        </Grid>
        
        <!--Buttons-->
        <uc:DetailViewFooterUserControl x:Name="UserControlDetailViewFooter" DeleteCommand="{Binding DeleteCommand}" ClearCommand="{Binding ClearCommand}" SaveCommand="{Binding SaveCommand}"
            SaveEnabled="{tsfBinding:DataOperation Path=(Validation.HasError)}" />

        <sdk:DataGrid x:Name="DataGridList" ItemsSource="{Binding CurrentPage}" SelectedItem="{Binding Path=CurrentItem, Mode=TwoWay}" Height="460" VerticalScrollBarVisibility="Auto" Width="600"
            PreviewKeyDown="DataGrid_PreviewKeyDown" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Sorting="DataGrid_Sorting" SelectedIndex="{tsfBinding:Column Path=CurrentSelectedIndex}">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="Label" Width="*" Binding="{tsfBinding:Column Path=Label}" IsReadOnly="True"/>
                <sdk:DataGridTextColumn Header=" Mask value" Width="*" Binding="{tsfBinding:Column Path=MaskValue}" />
                <sdk:DataGridTextColumn Header="Load Order" Width="2*" Binding="{tsfBinding:Column Path=LoadOrder}" />
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

        <uc:DataPagerUserControl Grid.Row="4" Grid.Column="0"  Grid.ColumnSpan="4" CurrentPageNumber="{Binding CurrentPageNumber}" PageCount="{Binding PageCount}"
                                FirstCommand="{Binding FirstCommand}" PreviousCommand="{Binding PreviousCommand}"
                                NextCommand="{Binding NextCommand}" LastCommand="{Binding LastCommand}"/>
        
        
    </StackPanel>

</UserControl>
